/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.notaria.guerrasalas.be;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "IGV")
@NamedQueries({
    @NamedQuery(name = "Igv.findAll", query = "SELECT i FROM Igv i ORDER BY i.fechaCreacion DESC"),
    @NamedQuery(name = "Igv.findByIdIgv", query = "SELECT i FROM Igv i WHERE i.idIgv = :idIgv"),
    @NamedQuery(name = "Igv.findActive", query = "SELECT i FROM Igv i WHERE i.fechaBaja IS NULL")
})
public class Igv implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_IGV", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long idIgv;
    @Basic(optional = false)
    @Column(name = "VALOR", nullable = false, precision = 4, scale = 2)
    private Double valor=0.0d;
    @Basic(optional = false)
    @Column(name = "FECHA_CREACION", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaCreacion = new Date();
    @Column(name = "FECHA_BAJA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaBaja;
    @JoinColumn(name = "FID_USUARIO", referencedColumnName = "ID_USUARIO", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Usuario usuario;

    public Igv() {
    }

    public Igv(Long idIgv) {
        this.idIgv = idIgv;
    }

    public Igv(Long idIgv, Double valor, Date fechaCreacion) {
        this.idIgv = idIgv;
        this.valor = valor;
        this.fechaCreacion = fechaCreacion;
    }

    public Long getIdIgv() {
        return idIgv;
    }

    public void setIdIgv(Long idIgv) {
        this.idIgv = idIgv;
    }

    public Double getValor() {
        return valor;
    }

    public void setValor(Double valor) {
        this.valor = valor;
    }

    public Date getFechaCreacion() {
        return fechaCreacion;
    }

    public void setFechaCreacion(Date fechaCreacion) {
        this.fechaCreacion = fechaCreacion;
    }

    public Date getFechaBaja() {
        return fechaBaja;
    }

    public void setFechaBaja(Date fechaBaja) {
        this.fechaBaja = fechaBaja;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Igv other = (Igv) obj;
        if (this.idIgv != other.idIgv && (this.idIgv == null || !this.idIgv.equals(other.idIgv))) {
            return false;
        }
        return true;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 67 * hash + (this.idIgv != null ? this.idIgv.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return idIgv.toString();
    }
}
